package action;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Professor;

public class ExcluirProfessorAction extends ManterProfessorAction {

    @Override
    public void setParametros(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        try {
            int matriculaProfessor = Integer.parseInt(request.getParameter("matricula"));
            Professor professor = Professor.obterProfessor(matriculaProfessor);
            request.setAttribute("professor", professor);
            request.setAttribute("editar", "readonly");
            request.setAttribute("excluir", "readonly");
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

    @Override
    public void efetuaPersistencia(Professor professor) throws ServletException {
        try {
            professor.excluir();
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

}
